/*
 * Module:	Global include file
 * Author:	Lvjianfeng
 * Date:	2011.8
 */

#ifndef _GLOBAL_H_
#define _GLOBAL_H_



#include "stdint.h"
// #include <string.h>
#include "devcomm_config.h"
//#include "devfs_config.h"
#include "devos_config.h"
//#include "cgms_config.h"

//Constant define
#define uint				uint32
#define sint				sint32

#ifndef NULL
	#define NULL			0
#endif

#define REG_MASK_1_BIT		0x01
#define REG_MASK_2_BIT		0x03
#define REG_MASK_3_BIT		0x07
#define REG_MASK_4_BIT		0x0F
#define REG_MASK_5_BIT		0x1F
#define REG_MASK_6_BIT		0x3F
#define REG_MASK_7_BIT		0x7F
#define REG_MASK_8_BIT		0xFF

#define REG_WRITE_FIELD(reg, field, mask, value)	( (reg) = ((reg) & (~((mask) << (field)))) | ((value) << (field)) )
#define REG_READ_FIELD(reg, field, mask)			( ((reg) >> (field)) & (mask) )
#define REG_SET_BIT(reg, field)						( (reg) |=  (1 << (field)) )
#define REG_CLEAR_BIT(reg, field)					( (reg) &= ~(1 << (field)) )
#define REG_REVERSE_BIT(reg, field)					( (reg) ^=  (1 << (field)) )
#define REG_GET_BIT(reg, field)						( (reg) &   (1 << (field)) )


//Type definition


// typedef signed   char   int8;
// typedef unsigned char   uint8;

// typedef signed   short  int16;
// typedef unsigned short  uint16;

// typedef signed   long   int32;
// typedef unsigned long   uint32;



typedef int8_t   int8;
typedef uint8_t   uint8;

typedef int16_t  int16;
typedef uint16_t  uint16;

typedef int32_t   int32;
typedef uint32_t   uint32;

typedef signed char			sint8;
typedef signed short int	sint16;
typedef signed long int		sint32;
typedef long long			int64;
typedef unsigned long long	uint64;
typedef signed long	long	sint64;
typedef float				float32;
typedef double				float64;
//typedef unsigned char		BOOL;

#define UINT8_MAX           255
#define UINT16_MAX          65535

typedef enum 
{
	FUNCTION_OK = 1,
	FUNCTION_FAIL = 0
} function_return;

#endif
